package com.sakura.util.minio.config;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.Serializable;

/**
 * @author : Sakura
 * @Date : 2023/12/1 14:57
 * @Description : TODO
 */
@Data
@Configuration
public class MinIOConfigProperties implements Serializable {

    @Value("${minio.accessKey}")
    private String accessKey;

    @Value("${minio.secretKey}")
    private String secretKey;

    @Value("${minio.bucketName}")
    private String bucketName;

    @Value("${minio.endpoint}")
    private String endpoint;

    @Value("${minio.readPath}")
    private String readPath;
    @Bean
    public MinioClient buildMinioClient(){
        return MinioClient
                .builder()
                .credentials(accessKey, secretKey)
                .endpoint(endpoint)
                .build();
    }
}
